{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#作业第二部分\n",
    "#采用KMeans聚类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入必要的工具包\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.cluster import KMeans\n",
    "from sklearn.cluster import MiniBatchKMeans\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "from sklearn import metrics\n",
    "from sklearn.decomposition import PCA\n",
    "import time\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>event_id</th>\n",
       "      <th>user_id</th>\n",
       "      <th>start_time</th>\n",
       "      <th>city</th>\n",
       "      <th>state</th>\n",
       "      <th>zip</th>\n",
       "      <th>country</th>\n",
       "      <th>lat</th>\n",
       "      <th>lng</th>\n",
       "      <th>...</th>\n",
       "      <th>c_92</th>\n",
       "      <th>c_93</th>\n",
       "      <th>c_94</th>\n",
       "      <th>c_95</th>\n",
       "      <th>c_96</th>\n",
       "      <th>c_97</th>\n",
       "      <th>c_98</th>\n",
       "      <th>c_99</th>\n",
       "      <th>c_100</th>\n",
       "      <th>c_other</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>684921758</td>\n",
       "      <td>3647864012</td>\n",
       "      <td>2012-10-31T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>244999119</td>\n",
       "      <td>3476440521</td>\n",
       "      <td>2012-11-03T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>3928440935</td>\n",
       "      <td>517514445</td>\n",
       "      <td>2012-11-05T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>2582345152</td>\n",
       "      <td>781585781</td>\n",
       "      <td>2012-10-30T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>1051165850</td>\n",
       "      <td>1016098580</td>\n",
       "      <td>2012-09-27T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 111 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0    event_id     user_id                start_time city state  \\\n",
       "0           0   684921758  3647864012  2012-10-31T00:00:00.001Z  NaN   NaN   \n",
       "1           1   244999119  3476440521  2012-11-03T00:00:00.001Z  NaN   NaN   \n",
       "2           2  3928440935   517514445  2012-11-05T00:00:00.001Z  NaN   NaN   \n",
       "3           3  2582345152   781585781  2012-10-30T00:00:00.001Z  NaN   NaN   \n",
       "4           4  1051165850  1016098580  2012-09-27T00:00:00.001Z  NaN   NaN   \n",
       "\n",
       "   zip country  lat  lng    ...      c_92  c_93  c_94  c_95  c_96  c_97  c_98  \\\n",
       "0  NaN     NaN  NaN  NaN    ...         0     1     0     0     0     0     0   \n",
       "1  NaN     NaN  NaN  NaN    ...         0     0     0     0     0     0     0   \n",
       "2  NaN     NaN  NaN  NaN    ...         0     0     0     0     0     0     0   \n",
       "3  NaN     NaN  NaN  NaN    ...         0     0     0     0     0     0     0   \n",
       "4  NaN     NaN  NaN  NaN    ...         0     0     0     0     0     0     0   \n",
       "\n",
       "   c_99  c_100  c_other\\n  \n",
       "0     0      0          9  \n",
       "1     0      0          7  \n",
       "2     0      0         12  \n",
       "3     0      0          8  \n",
       "4     0      0          9  \n",
       "\n",
       "[5 rows x 111 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#导入之前提取出来的数据\n",
    "data = pd.read_csv('./w4_data/new.csv')\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(13418, 111)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "多了一列Unnamed:0 应该是在产生数据是将index也写进去了，在提取数据里需去掉"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 13418 entries, 0 to 13417\n",
      "Columns: 111 entries, Unnamed: 0 to c_other\n",
      "\n",
      "dtypes: float64(2), int64(104), object(5)\n",
      "memory usage: 11.4+ MB\n"
     ]
    }
   ],
   "source": [
    "data.info() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>event_id</th>\n",
       "      <th>user_id</th>\n",
       "      <th>lat</th>\n",
       "      <th>lng</th>\n",
       "      <th>c_1</th>\n",
       "      <th>c_2</th>\n",
       "      <th>c_3</th>\n",
       "      <th>c_4</th>\n",
       "      <th>c_5</th>\n",
       "      <th>...</th>\n",
       "      <th>c_92</th>\n",
       "      <th>c_93</th>\n",
       "      <th>c_94</th>\n",
       "      <th>c_95</th>\n",
       "      <th>c_96</th>\n",
       "      <th>c_97</th>\n",
       "      <th>c_98</th>\n",
       "      <th>c_99</th>\n",
       "      <th>c_100</th>\n",
       "      <th>c_other</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>13418.000000</td>\n",
       "      <td>1.341800e+04</td>\n",
       "      <td>1.341800e+04</td>\n",
       "      <td>8062.000000</td>\n",
       "      <td>8062.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "      <td>13418.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>6708.500000</td>\n",
       "      <td>2.140873e+09</td>\n",
       "      <td>2.134713e+09</td>\n",
       "      <td>25.727517</td>\n",
       "      <td>-24.807209</td>\n",
       "      <td>2.359964</td>\n",
       "      <td>1.464972</td>\n",
       "      <td>1.323372</td>\n",
       "      <td>0.888732</td>\n",
       "      <td>1.159711</td>\n",
       "      <td>...</td>\n",
       "      <td>0.064913</td>\n",
       "      <td>0.083992</td>\n",
       "      <td>0.093755</td>\n",
       "      <td>0.070502</td>\n",
       "      <td>0.082427</td>\n",
       "      <td>0.233790</td>\n",
       "      <td>0.082874</td>\n",
       "      <td>0.076837</td>\n",
       "      <td>0.073558</td>\n",
       "      <td>57.554777</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>3873.587291</td>\n",
       "      <td>1.232469e+09</td>\n",
       "      <td>1.254357e+09</td>\n",
       "      <td>21.162472</td>\n",
       "      <td>91.900619</td>\n",
       "      <td>19.331141</td>\n",
       "      <td>2.959769</td>\n",
       "      <td>2.720104</td>\n",
       "      <td>1.972209</td>\n",
       "      <td>15.695718</td>\n",
       "      <td>...</td>\n",
       "      <td>0.309890</td>\n",
       "      <td>0.377730</td>\n",
       "      <td>0.388404</td>\n",
       "      <td>0.312148</td>\n",
       "      <td>0.503164</td>\n",
       "      <td>15.553234</td>\n",
       "      <td>0.356777</td>\n",
       "      <td>0.455338</td>\n",
       "      <td>0.337954</td>\n",
       "      <td>110.916584</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.040700e+05</td>\n",
       "      <td>1.329876e+06</td>\n",
       "      <td>-86.151000</td>\n",
       "      <td>-157.991000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>3354.250000</td>\n",
       "      <td>1.081551e+09</td>\n",
       "      <td>1.027696e+09</td>\n",
       "      <td>3.608000</td>\n",
       "      <td>-96.886500</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>14.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>6708.500000</td>\n",
       "      <td>2.122509e+09</td>\n",
       "      <td>2.150758e+09</td>\n",
       "      <td>34.040000</td>\n",
       "      <td>-76.794000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>38.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>10062.750000</td>\n",
       "      <td>3.206782e+09</td>\n",
       "      <td>3.220623e+09</td>\n",
       "      <td>42.983750</td>\n",
       "      <td>98.656750</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>75.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>13417.000000</td>\n",
       "      <td>4.294677e+09</td>\n",
       "      <td>4.294033e+09</td>\n",
       "      <td>61.498000</td>\n",
       "      <td>174.777000</td>\n",
       "      <td>2186.000000</td>\n",
       "      <td>82.000000</td>\n",
       "      <td>85.000000</td>\n",
       "      <td>71.000000</td>\n",
       "      <td>1801.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>23.000000</td>\n",
       "      <td>1801.000000</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>16.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>9664.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 106 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Unnamed: 0      event_id       user_id          lat          lng  \\\n",
       "count  13418.000000  1.341800e+04  1.341800e+04  8062.000000  8062.000000   \n",
       "mean    6708.500000  2.140873e+09  2.134713e+09    25.727517   -24.807209   \n",
       "std     3873.587291  1.232469e+09  1.254357e+09    21.162472    91.900619   \n",
       "min        0.000000  1.040700e+05  1.329876e+06   -86.151000  -157.991000   \n",
       "25%     3354.250000  1.081551e+09  1.027696e+09     3.608000   -96.886500   \n",
       "50%     6708.500000  2.122509e+09  2.150758e+09    34.040000   -76.794000   \n",
       "75%    10062.750000  3.206782e+09  3.220623e+09    42.983750    98.656750   \n",
       "max    13417.000000  4.294677e+09  4.294033e+09    61.498000   174.777000   \n",
       "\n",
       "                c_1           c_2           c_3           c_4           c_5  \\\n",
       "count  13418.000000  13418.000000  13418.000000  13418.000000  13418.000000   \n",
       "mean       2.359964      1.464972      1.323372      0.888732      1.159711   \n",
       "std       19.331141      2.959769      2.720104      1.972209     15.695718   \n",
       "min        0.000000      0.000000      0.000000      0.000000      0.000000   \n",
       "25%        0.000000      0.000000      0.000000      0.000000      0.000000   \n",
       "50%        1.000000      0.000000      0.000000      0.000000      0.000000   \n",
       "75%        3.000000      2.000000      2.000000      1.000000      1.000000   \n",
       "max     2186.000000     82.000000     85.000000     71.000000   1801.000000   \n",
       "\n",
       "           ...               c_92          c_93          c_94          c_95  \\\n",
       "count      ...       13418.000000  13418.000000  13418.000000  13418.000000   \n",
       "mean       ...           0.064913      0.083992      0.093755      0.070502   \n",
       "std        ...           0.309890      0.377730      0.388404      0.312148   \n",
       "min        ...           0.000000      0.000000      0.000000      0.000000   \n",
       "25%        ...           0.000000      0.000000      0.000000      0.000000   \n",
       "50%        ...           0.000000      0.000000      0.000000      0.000000   \n",
       "75%        ...           0.000000      0.000000      0.000000      0.000000   \n",
       "max        ...           7.000000      9.000000     10.000000      9.000000   \n",
       "\n",
       "               c_96          c_97          c_98          c_99         c_100  \\\n",
       "count  13418.000000  13418.000000  13418.000000  13418.000000  13418.000000   \n",
       "mean       0.082427      0.233790      0.082874      0.076837      0.073558   \n",
       "std        0.503164     15.553234      0.356777      0.455338      0.337954   \n",
       "min        0.000000      0.000000      0.000000      0.000000      0.000000   \n",
       "25%        0.000000      0.000000      0.000000      0.000000      0.000000   \n",
       "50%        0.000000      0.000000      0.000000      0.000000      0.000000   \n",
       "75%        0.000000      0.000000      0.000000      0.000000      0.000000   \n",
       "max       23.000000   1801.000000      9.000000     16.000000      7.000000   \n",
       "\n",
       "          c_other\\n  \n",
       "count  13418.000000  \n",
       "mean      57.554777  \n",
       "std      110.916584  \n",
       "min        0.000000  \n",
       "25%       14.000000  \n",
       "50%       38.000000  \n",
       "75%       75.000000  \n",
       "max     9664.000000  \n",
       "\n",
       "[8 rows x 106 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#查看数据特征\n",
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#作业要求根据活动的关键词（count_1, count_2, ..., count_100，count_other属性）做聚类\n",
    "#去掉不需要的列\n",
    "cluster_data = data.drop(['Unnamed: 0','event_id','user_id','lat','lng','start_time','city','state','zip','country'], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(13418, 101)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cluster_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据标准化\n",
    "# 初始化特征的标准化器\n",
    "ss_X = StandardScaler()\n",
    "\n",
    "# 分别对训练和测试数据的特征进行标准化处理\n",
    "cluster_data = ss_X.fit_transform(cluster_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "numpy.ndarray"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(cluster_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "cols=data.columns "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(13418, 47)\n"
     ]
    }
   ],
   "source": [
    "#对数据进行PCA降维\n",
    "pca = PCA(n_components=0.75)\n",
    "pca.fit(cluster_data)\n",
    "\n",
    "cluster_data_pca = pca.transform(cluster_data)\n",
    "# 降维后的特征维数\n",
    "print(cluster_data_pca.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "作业任务2-3：聚类， CH_scores计算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义一个用MiniBatchKMeans进行的聚类的函数\n",
    "#分别计算calinski_harabaz_score和silhouette_score\n",
    "def MiniBatchKMeans_analysis(K, data):\n",
    "    start = time.time()\n",
    "    \n",
    "    print(\"K-means begin with clusters: {}\".format(K));\n",
    "    \n",
    "    #除n_clusters外使用默认参数进行训练\n",
    "    mb_kmeans = MiniBatchKMeans(n_clusters=K)#, init='k-means++', n_init=10, max_iter=300, tol=0.0001)\n",
    "    mb_kmeans.fit(data)\n",
    "\n",
    "    CH_score = metrics.calinski_harabaz_score(data,mb_kmeans.predict(data))\n",
    "    SH_score = metrics.silhouette_score(data,mb_kmeans.predict(data))\n",
    "        \n",
    "    end = time.time()\n",
    "    print(\"calinski_harabaz_score: {}, silhouette_score: {}, time elaps:{}\".format(CH_score, SH_score,int(end-start)))\n",
    "    \n",
    "    return CH_score,SH_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters: 10\n",
      "calinski_harabaz_score: 462.100045734794, silhouette_score: 0.08392041795142476, time elaps:7\n",
      "K-means begin with clusters: 20\n",
      "calinski_harabaz_score: 278.32448153257104, silhouette_score: -0.07551419019430716, time elaps:6\n",
      "K-means begin with clusters: 30\n",
      "calinski_harabaz_score: 215.29455093187275, silhouette_score: 0.061607189771341504, time elaps:6\n",
      "K-means begin with clusters: 40\n",
      "calinski_harabaz_score: 134.61229769160306, silhouette_score: -0.127139100583476, time elaps:6\n",
      "K-means begin with clusters: 50\n",
      "calinski_harabaz_score: 121.7389128185144, silhouette_score: -0.15741029525924013, time elaps:6\n",
      "K-means begin with clusters: 60\n",
      "calinski_harabaz_score: 119.14064596722065, silhouette_score: -0.04872951006193715, time elaps:6\n",
      "K-means begin with clusters: 70\n",
      "calinski_harabaz_score: 110.22878690977657, silhouette_score: 0.011285766344051373, time elaps:6\n",
      "K-means begin with clusters: 80\n",
      "calinski_harabaz_score: 102.42524597395467, silhouette_score: -0.10961867490469453, time elaps:6\n",
      "K-means begin with clusters: 90\n",
      "calinski_harabaz_score: 91.34408433832512, silhouette_score: -0.20933866621642852, time elaps:6\n",
      "K-means begin with clusters: 100\n",
      "calinski_harabaz_score: 97.5005410734326, silhouette_score: -0.02373327819141839, time elaps:6\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = range(10,101,10)\n",
    "#保存评估价\n",
    "Mini_CH_scores = []\n",
    "Mini_SH_scores = []\n",
    "for K in Ks:\n",
    "    ch,sh = MiniBatchKMeans_analysis(K, cluster_data_pca) #对降维后的数据进行聚类\n",
    "    Mini_CH_scores.append(ch)\n",
    "    Mini_SH_scores.append(sh)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters: 10\n",
      "calinski_harabaz_score: 333.71373231004566, silhouette_score: 0.10944433718462601, time elaps:6\n",
      "K-means begin with clusters: 20\n",
      "calinski_harabaz_score: 150.95763506698063, silhouette_score: -0.17247041185312623, time elaps:6\n",
      "K-means begin with clusters: 30\n",
      "calinski_harabaz_score: 123.48938861945648, silhouette_score: 0.03319732235217427, time elaps:6\n",
      "K-means begin with clusters: 40\n",
      "calinski_harabaz_score: 100.25615732238582, silhouette_score: -0.0910782729762011, time elaps:6\n",
      "K-means begin with clusters: 50\n",
      "calinski_harabaz_score: 76.63508126427777, silhouette_score: -0.1091128464455877, time elaps:6\n",
      "K-means begin with clusters: 60\n",
      "calinski_harabaz_score: 80.79149594088335, silhouette_score: -0.05834021897187135, time elaps:6\n",
      "K-means begin with clusters: 70\n",
      "calinski_harabaz_score: 70.44885809525327, silhouette_score: -0.17230511317975183, time elaps:6\n",
      "K-means begin with clusters: 80\n",
      "calinski_harabaz_score: 71.07105097907237, silhouette_score: -0.11951369572446566, time elaps:6\n",
      "K-means begin with clusters: 90\n",
      "calinski_harabaz_score: 62.52967638823194, silhouette_score: -0.19000283086494704, time elaps:6\n",
      "K-means begin with clusters: 100\n",
      "calinski_harabaz_score: 66.7784380655841, silhouette_score: -0.10570987151930285, time elaps:6\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = range(10,101,10)\n",
    "#保存评估价\n",
    "Mini_CH_scores = []\n",
    "Mini_SH_scores = []\n",
    "for K in Ks:\n",
    "    ch,sh = MiniBatchKMeans_analysis(K, cluster_data) #对未降维的数据进行聚类\n",
    "    Mini_CH_scores.append(ch)\n",
    "    Mini_SH_scores.append(sh)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从上面数据可以看出，使用降维后的数据，测得的calinski_harabaz_score普遍较大，silhouette_score普遍较小"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义一个用MiniBatchKMeans进行的聚类的函数，自定义部分参数\n",
    "#分别计算calinski_harabaz_score和silhouette_score\n",
    "def MiniBatchKMeans_analysis2(K, data):\n",
    "    start = time.time()\n",
    "    \n",
    "    print(\"K-means begin with clusters: {}\".format(K));\n",
    "    \n",
    "    #除n_clusters外使用默认参数进行训练\n",
    "    mb_kmeans = MiniBatchKMeans(n_clusters=K, init='k-means++', n_init=10, max_iter=300, tol=0.0001)\n",
    "    mb_kmeans.fit(data)\n",
    "\n",
    "    CH_score = metrics.calinski_harabaz_score(data,mb_kmeans.predict(data))\n",
    "    SH_score = metrics.silhouette_score(data,mb_kmeans.predict(data))\n",
    "        \n",
    "    end = time.time()\n",
    "    print(\"calinski_harabaz_score: {}, silhouette_score: {}, time elaps:{}\".format(CH_score, SH_score,int(end-start)))\n",
    "    \n",
    "    return CH_score,SH_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters: 10\n",
      "calinski_harabaz_score: 246.36957754450083, silhouette_score: -0.10108899048826103, time elaps:7\n",
      "K-means begin with clusters: 20\n",
      "calinski_harabaz_score: 164.34209226887748, silhouette_score: -0.09741644605438511, time elaps:7\n",
      "K-means begin with clusters: 30\n",
      "calinski_harabaz_score: 118.94027466717361, silhouette_score: -0.0984138353773095, time elaps:6\n",
      "K-means begin with clusters: 40\n",
      "calinski_harabaz_score: 119.15190690857584, silhouette_score: -0.027170026983843503, time elaps:6\n",
      "K-means begin with clusters: 50\n",
      "calinski_harabaz_score: 82.00945085499724, silhouette_score: -0.10987493535861934, time elaps:6\n",
      "K-means begin with clusters: 60\n",
      "calinski_harabaz_score: 81.94562409791399, silhouette_score: -0.07598868875270837, time elaps:6\n",
      "K-means begin with clusters: 70\n",
      "calinski_harabaz_score: 65.73956444786266, silhouette_score: -0.1154941691369694, time elaps:6\n",
      "K-means begin with clusters: 80\n",
      "calinski_harabaz_score: 62.92770447618965, silhouette_score: -0.14163305371609605, time elaps:6\n",
      "K-means begin with clusters: 90\n",
      "calinski_harabaz_score: 61.046763072571366, silhouette_score: -0.12482027160361167, time elaps:7\n",
      "K-means begin with clusters: 100\n",
      "calinski_harabaz_score: 53.68057439828724, silhouette_score: -0.15463612370048904, time elaps:7\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = range(10,101,10)\n",
    "#保存评估价\n",
    "Mini_CH_scores = []\n",
    "Mini_SH_scores = []\n",
    "for K in Ks:\n",
    "    ch,sh = MiniBatchKMeans_analysis2(K, cluster_data) #对未降维的数据进行聚类\n",
    "    Mini_CH_scores.append(ch)\n",
    "    Mini_SH_scores.append(sh)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters: 10\n",
      "calinski_harabaz_score: 453.5928867620064, silhouette_score: -0.0031790388259213876, time elaps:6\n",
      "K-means begin with clusters: 20\n",
      "calinski_harabaz_score: 280.6720291056219, silhouette_score: 0.09280072792791287, time elaps:6\n",
      "K-means begin with clusters: 30\n",
      "calinski_harabaz_score: 311.0477450268749, silhouette_score: 0.10036839078872101, time elaps:6\n",
      "K-means begin with clusters: 40\n",
      "calinski_harabaz_score: 171.38421154445004, silhouette_score: -0.004765639757857559, time elaps:6\n",
      "K-means begin with clusters: 50\n",
      "calinski_harabaz_score: 146.05921841011522, silhouette_score: -0.010398089720973648, time elaps:6\n",
      "K-means begin with clusters: 60\n",
      "calinski_harabaz_score: 116.97247803472314, silhouette_score: 0.011150277650827647, time elaps:6\n",
      "K-means begin with clusters: 70\n",
      "calinski_harabaz_score: 122.41323059168377, silhouette_score: -0.04420101856131891, time elaps:7\n",
      "K-means begin with clusters: 80\n",
      "calinski_harabaz_score: 111.18367225871074, silhouette_score: -0.11455264597171298, time elaps:6\n",
      "K-means begin with clusters: 90\n",
      "calinski_harabaz_score: 93.44333984341414, silhouette_score: -0.02229370663704452, time elaps:6\n",
      "K-means begin with clusters: 100\n",
      "calinski_harabaz_score: 108.75775584342811, silhouette_score: -0.01506506637435142, time elaps:6\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = range(10,101,10)\n",
    "#保存评估价\n",
    "Mini_CH_scores = []\n",
    "Mini_SH_scores = []\n",
    "for K in Ks:\n",
    "    ch,sh = MiniBatchKMeans_analysis2(K, cluster_data_pca) #对降维的数据进行聚类\n",
    "    Mini_CH_scores.append(ch)\n",
    "    Mini_SH_scores.append(sh)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "每次运行得到的数据都不一样，这个问题我已经遇到多次，希望助教老师帮忙在我作业上分析一下是何原因，谢谢"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "再用KMeans进行聚类，看看与MiniBatchKMeans相差多少"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义一个用KMeans进行的聚类的函数\n",
    "def KMeans_analysis(K, data):\n",
    "    start = time.time()\n",
    "    \n",
    "    print(\"K-means begin with clusters: {}\".format(K));\n",
    "    \n",
    "    #K-means,在训练集上训练\n",
    "    mb_kmeans = KMeans(n_clusters=K, init='k-means++', n_init=10, max_iter=300, tol=0.0001, precompute_distances=True, n_jobs=8)\n",
    "    mb_kmeans.fit(data)\n",
    "\n",
    "    CH_score = metrics.calinski_harabaz_score(data,mb_kmeans.predict(data))\n",
    "    SH_score = metrics.silhouette_score(data,mb_kmeans.predict(data))\n",
    "        \n",
    "    end = time.time()\n",
    "    print(\"calinski_harabaz_score: {}, silhouette_score: {}, time elaps:{}\".format(CH_score, SH_score,int(end-start)))\n",
    "    \n",
    "    return CH_score,SH_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "range(10, 101, 10)\n",
      "K-means begin with clusters: 10\n",
      "calinski_harabaz_score: 596.0365411162621, silhouette_score: 0.1888606033222907, time elaps:9\n",
      "K-means begin with clusters: 20\n",
      "calinski_harabaz_score: 358.142701678014, silhouette_score: 0.18851040076687817, time elaps:9\n",
      "K-means begin with clusters: 30\n",
      "calinski_harabaz_score: 272.5013615715805, silhouette_score: 0.16977256871511193, time elaps:11\n",
      "K-means begin with clusters: 40\n",
      "calinski_harabaz_score: 222.86060304851938, silhouette_score: 0.13504895857756552, time elaps:12\n",
      "K-means begin with clusters: 50\n",
      "calinski_harabaz_score: 194.10507302121465, silhouette_score: 0.134132440970233, time elaps:13\n",
      "K-means begin with clusters: 60\n",
      "calinski_harabaz_score: 169.45420950253674, silhouette_score: 0.11691601078523643, time elaps:14\n",
      "K-means begin with clusters: 70\n",
      "calinski_harabaz_score: 154.69847490352834, silhouette_score: 0.11360927964455363, time elaps:15\n",
      "K-means begin with clusters: 80\n",
      "calinski_harabaz_score: 142.27433852187553, silhouette_score: 0.14505494576402536, time elaps:14\n",
      "K-means begin with clusters: 90\n",
      "calinski_harabaz_score: 132.18062506377416, silhouette_score: 0.08046481941140199, time elaps:16\n",
      "K-means begin with clusters: 100\n",
      "calinski_harabaz_score: 123.15288106932488, silhouette_score: 0.12164522264589671, time elaps:16\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = range(10,101,10)\n",
    "print(Ks)\n",
    "CH_scores = []\n",
    "SH_scores = []\n",
    "for K in Ks:\n",
    "    ch,sh = KMeans_analysis(K, cluster_data)\n",
    "    CH_scores.append(ch)\n",
    "    SH_scores.append(sh)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "range(10, 101, 10)\n",
      "K-means begin with clusters: 10\n",
      "calinski_harabaz_score: 875.5339595266337, silhouette_score: 0.2537476763478694, time elaps:8\n",
      "K-means begin with clusters: 20\n",
      "calinski_harabaz_score: 561.3411059206194, silhouette_score: 0.2359295296157772, time elaps:8\n",
      "K-means begin with clusters: 30\n",
      "calinski_harabaz_score: 435.6796800731846, silhouette_score: 0.2039428586750076, time elaps:9\n",
      "K-means begin with clusters: 40\n",
      "calinski_harabaz_score: 358.1776228625202, silhouette_score: 0.20627421922509545, time elaps:10\n",
      "K-means begin with clusters: 50\n",
      "calinski_harabaz_score: 313.078588544589, silhouette_score: 0.1694334330885829, time elaps:11\n",
      "K-means begin with clusters: 60\n",
      "calinski_harabaz_score: 278.2147888319903, silhouette_score: 0.18086703657619058, time elaps:13\n",
      "K-means begin with clusters: 70\n",
      "calinski_harabaz_score: 253.28812576439833, silhouette_score: 0.14092376769864945, time elaps:14\n",
      "K-means begin with clusters: 80\n",
      "calinski_harabaz_score: 233.16647456491862, silhouette_score: 0.17407945975937397, time elaps:14\n",
      "K-means begin with clusters: 90\n",
      "calinski_harabaz_score: 217.22088777173852, silhouette_score: 0.17025235832327698, time elaps:16\n",
      "K-means begin with clusters: 100\n",
      "calinski_harabaz_score: 202.4536965227131, silhouette_score: 0.16027445979117672, time elaps:16\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = range(10,101,10)\n",
    "print(Ks)\n",
    "CH_scores = []\n",
    "SH_scores = []\n",
    "for K in Ks:\n",
    "    ch,sh = KMeans_analysis(K, cluster_data_pca) #降维数据上再试试\n",
    "    CH_scores.append(ch)\n",
    "    SH_scores.append(sh)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "作业任务4：结果显示/分析\n",
    "从上面测试结果来看，使用降维后数据，使用KMeans方法进行聚类得到的结果最佳：\n",
    "silhouette_score更接近1,calinski_harabaz_score更大\n",
    "但是silhouette_score并没有大于0.5,说明聚类的结果并不好"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f712a5eb7b8>]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0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yULhmmqEo09DwY6A+2APMLwxMGy5bNRnTr7f6OgP0o1vI5uJrsQ+L6ZrQGeIQzf/BFobmaJC9tUed3gDFUGlLn7guj584Tgz8bPxmXAJ+5e7u57gBeAC8jez0ZCra63fTQU9EfhKK6jm7Hc/R53b+/uhYQDbbPd/XpgDjA02iwr3gsAd/8MWGdmp0SL+gIfkIWfDcKQTR8zaxb9n0m8F1n52aik3q+3rROmjoIdv/g6AAAArklEQVSZfQv4G7CMinHpXxPG6Z8FOhJdR9fdt8ZSZAzM7GLgV+4+yMy6EPbwWwKLgRvcfXec9dUXM+sNPA40BlYTrpvciCz8bJjZb4FrCDPVFgP/lzDunBWfDTObBFxM6FC5EfgN8CJVfBaiL8M/E2bpfAHc5O4lKalDQS8iktk0dCMikuEU9CIiGU5BLyKS4RT0IiIZTkEvIpLhFPQiIhlOQS8ikuEU9CIiGe7/A4qpZJU99rb8AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f712b0decc0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#将最佳结果可视化\n",
    "plt.plot(Ks, np.array(CH_scores), 'b-')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f712099c320>]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3X28lHP+x/HXpzsltUTbpvuSm6yIU1j3i92yNvfknmVbEnLfnUSEjpIIhbVYtGltsm4qluz6uekk0o1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Jm1BboAbwDNQgifAKT+/Gl0lWXVaOBqoGy95O2Br4K36IbNWG4zBtoDJcCDqeGu+82sIQl9b4QQlgO3AcuAT4D/ArNI7vujzKbeD1u8VO2PUehniJltA/wV6BdC+DrqeqJgZkcDK0IIs8pfXcmmSTllrA6wN3BPCKEL8C0JGcqpTGqs+higHbAj0BAfwqgoKe+PqtTI/x2FfgaYWV088B8NITyZuvo/ZtY8dXtzYEVU9WXRAUBPM/sAmIAP8YwGtjWzslXaNme5zXxXDBSHEN5IXZ6Efwgk8b0BcASwNIRQEkJYCzwJ/ILkvj/KbOr9UJ2lajdJoV9NZmbAA8CCEMKocjdNAc5O/f1sfKw/1kIIA0IILUMIbfEDdP8IvmTmS8CJqc0S8VoAhBA+BT4ys11SVx0OzCeB742UZcB+ZrZ16v9N2euRyPdHOZt6P0wBzkqdxbMf8N+yYaDq0OSsajKzA4F/Au+yfhx7ID6uPxFojb/ZTwohfBFJkREws0OBK0MIR5tZe3zPvwkwGzgjhPB9lPVli5ntBdwP1AOWAOfiO1uJfG+Y2fXAKfhZb7OB8/Fx6kS8P8zsceBQvJvmf4DrgMlU8n5IfTDehZ/tswo4N4RQ7WUFFfoiIgmi4R0RkQRR6IuIJIhCX0QkQRT6IiIJotAXEUkQhb6ISIIo9EVEEkShLyKSIP8PR/KFIr4BzuEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f712b0dee48>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(Ks, np.array(SH_scores), 'b-')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以看到K=10时结果最佳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh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7NuD0L2FWhaykrY8wYnLBvtdb+KHl4d+rrXvLne5W6Pp+dDVxijGnD6aY7H6fFf2Tyqz9U33u9A9hhrX0hefsHOB8A1foeA1wAvG2t3WOtPQz8CDiL6n6fU7ze15IyLSiB/2vgxOSo/licAZ8nKnxNvkv2Xz8AbLXWfjPjT08AVyV/vwpYPdzXVg7W2puttbOstQ047+kvrbUx4GngL5N3q5rXC2CtfRd4xxhzUvLQEuB1qvQ9TmoHzjTG1CT/H0+95qp9nzN4va9PAJ9KVuucCXyQ6vrJyVobiH/ARcBvgd8DzZW+njK9xkU4X+teBV5J/rsIp197LfC75M8plb7WMrz2c4Enk7/PBl4E3gT+HxCt9PX5/FpPBzYm3+f/BCZX+3sMfBV4A9gC/BsQrbb3GXgUZ4ziME4L/jNe7ytOl85dyTz7DU4FU97n0ExbEZGACEqXjohI4CnwRUQCQoEvIhIQCnwRkYBQ4IuIBIQCX0QkIBT4IiIBocAXEQmI/w+vEznF+q1FKAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f71209a8a90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#显示聚类结果\n",
    "#画出聚类结果，每一类用一种颜色\n",
    "colors = ['b','g','r','k','c','m','y','#e24fff','#524C90','#845868']\n",
    "\n",
    "K = 10\n",
    "mb_kmeans = mb_kmeans = KMeans(n_clusters=K, init='k-means++', n_init=10, max_iter=300, tol=0.0001, precompute_distances=True, n_jobs=8)\n",
    "mb_kmeans.fit(cluster_data_pca)\n",
    "y_train_pred = mb_kmeans.labels_\n",
    "for i in range(K):\n",
    "    index = np.nonzero(y_train_pred==i)[0]\n",
    "    x1 = cluster_data_pca[index,0]\n",
    "    x2 = cluster_data_pca[index,1]\n",
    "    for j in range(len(x1)):\n",
    "        if j < 200:  #每类打印20个\n",
    "            plt.scatter(x1[j],x2[j],color=colors[i])\n",
    "\n",
    "plt.axis([-10,100,-5,5])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "range(2, 11)\n",
      "K-means begin with clusters: 2\n",
      "calinski_harabaz_score: 2022.2992102628045, silhouette_score: 0.5387063267488498, time elaps:7\n",
      "K-means begin with clusters: 3\n",
      "calinski_harabaz_score: 1961.6961173085579, silhouette_score: 0.5352705073964755, time elaps:7\n",
      "K-means begin with clusters: 4\n",
      "calinski_harabaz_score: 1698.141127582039, silhouette_score: 0.35875789850368645, time elaps:8\n",
      "K-means begin with clusters: 5\n",
      "calinski_harabaz_score: 1458.0308925372105, silhouette_score: 0.29935796913850315, time elaps:7\n",
      "K-means begin with clusters: 6\n",
      "calinski_harabaz_score: 1289.86710432696, silhouette_score: 0.2975554879009285, time elaps:8\n",
      "K-means begin with clusters: 7\n",
      "calinski_harabaz_score: 1149.3701205542523, silhouette_score: 0.29414464335509716, time elaps:8\n",
      "K-means begin with clusters: 8\n",
      "calinski_harabaz_score: 1031.0143590720224, silhouette_score: 0.25340217763227424, time elaps:8\n",
      "K-means begin with clusters: 9\n",
      "calinski_harabaz_score: 958.0085940085874, silhouette_score: 0.2521767315821786, time elaps:8\n",
      "K-means begin with clusters: 10\n",
      "calinski_harabaz_score: 882.4629498751495, silhouette_score: 0.2341923162820841, time elaps:8\n"
     ]
    }
   ],
   "source": [
    "#调整K的取值再次测试\n",
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = range(2,11,1)\n",
    "print(Ks)\n",
    "CH_scores = []\n",
    "SH_scores = []\n",
    "for K in Ks:\n",
    "    ch,sh = KMeans_analysis(K, cluster_data_pca) #降维数据上再试试\n",
    "    CH_scores.append(ch)\n",
    "    SH_scores.append(sh)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从上面结果看，K=2时结果最佳，我认为是数据并没有明显的类别差异，所以无法准确的进行聚类操作，才会有这样的结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAFHVJREFUeJzt3X+MHOV9x/HP93447QIx8dlpWuy7Iy1Ni+I2SU8oKVVV4aYikECFqijRtiEi1Qmo1KNNlUKvEqKq/6haJXbV2OgUQgGvkqr50UCaVCVOUFVVoTkTigkmCU19hoQUczQGfES2z9/+MTt4b29mfz57uzvP+yWdzjs7NzPLoM/OPM/3ecbcXQCA4hvp9wEAADYGgQ8AkSDwASASBD4ARILAB4BIEPgAEAkCHwAiQeADQCQIfACIxFg/drp161afnp7ux64BYGgdOnToeXff1unf9yXwp6entbi42I9dA8DQMrOlbv6eJh0AiASBDwCRIPABIBIEPgBEgsAHgEgQ+AAQCQIfACJB4ANAJAh8AIgEgQ8AkSDwASASBD4ARILAB4BIEPgAEAkCHwAiQeADQCSCBb6ZjZrZN83si6G2CQAIJ+QV/pykIwG3BwAIKEjgm9l2SVdL+kSI7QEAwgt1hb9H0kcknQ20PQBAYF0Hvpm9W9Jz7n6oyXqzZrZoZovHjx/vdrcAgDaFuMK/XNI1ZnZU0qclXWFmB+pXcvcFd59x95lt27YF2C0AoB1dB7673+bu2919WtL7JH3V3X+36yMDAARFHT4ARGIs5Mbc/SFJD4XcJgAgDK7wASASBD4ARILAB4BIEPgAEAkCHwAiQeADQCQIfACIBIEPAJEg8AEgEgQ+AESCwAeASBD4ABAJAh8AIkHgA0AkCHwAiASBDwCRIPABIBIEPgBEgsAHgEgQ+AAQCQIfACJB4ANAJAh8AIgEgQ8AkSDwASASBD4ARILAB4BI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v0jS0zWvn6kuKywzm5b0VkkPS/opd39WSr4UJL2+f0cW3B5JH5F0tvp6QtKP3P1M9XXRzvUbJR2XdHe1GesTZnaeCnyO3f37kv5G0jElQX9C0iEV+zyn8s5rR5kWS+BbxrLClieZ2fmSPivpFnd/sd/H0ytm9m5Jz7n7odrFGasW6VyPSXqbpP3u/lZJJ1Wg5pss1XbrayVdLOlnJJ2npEmjXpHOczMd/X8eS+A/I2lHzevtkn7Qp2PpKTMbVxL2FXf/XHXx/6a3e9Xfz/Xr+AK7XNI1ZnZUSTPdFUqu+C+s3vpLxTvXz0h6xt0frr7+jJIvgKKeY0n6TUn/4+7H3f20pM9J+lUV+zyn8s5rR5kWS+B/Q9Il1V79TUo6fO7v8zEFV22/vkvSEXf/aM1b90u6vvrv6yV9YaOPrRfc/TZ33+7u00rO6VfdvSzpa5J+p7paYT6vJLn7DyU9bWZvqi7aJekJFfQcVx2T9HYzK1X/H08/c2HPc42883q/pA9Uq3XeLulE2vTTkLtH8SPpKknfkfTfkub7fTw9+oy/puS27jFJj1Z/rlLSrn1Q0nerv7f0+1h78Nl/Q9IXq/9+o6T/lPSUpH+U9Jp+H1/gz/oWSYvV8/xPkl5X9HMs6Q5JT0p6XNJ9kl5TtPMs6VNK+ihOK7mC/1DeeVXSpPPxap4dVlLB1HQfjLQFgEjE0qQDANEj8AEgEgQ+AESCwAeASBD4ABAJAh8AIkHgA0AkCHwAiMT/A334WfAOm7+cAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f7120962128>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#显示聚类结果\n",
    "#画出聚类结果，每一类用一种颜色\n",
    "colors = ['b','g']\n",
    "\n",
    "K = 2\n",
    "mb_kmeans = mb_kmeans = KMeans(n_clusters=K, init='k-means++', n_init=10, max_iter=300, tol=0.0001, precompute_distances=True, n_jobs=8)\n",
    "mb_kmeans.fit(cluster_data)\n",
    "y_train_pred = mb_kmeans.labels_\n",
    "for i in range(K):\n",
    "    index = np.nonzero(y_train_pred==i)[0]\n",
    "    x1 = cluster_data_pca[index,0]\n",
    "    x2 = cluster_data_pca[index,1]\n",
    "    for j in range(len(x1)):\n",
    "        if j < 200:  #每类打印200个\n",
    "            plt.scatter(x1[j],x2[j],color=colors[i])\n",
    "\n",
    "plt.axis([-10,100,-5,5])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "分析以上结果可知：\n",
    "1.本例中MiniBatchKMeans比KMeans速率快一倍，但是结果差很多\n",
    "2.降维对运算结果有一定影响，不一定是变好或是变坏，都有可能，计算速度也没有明显差别\n",
    "3.calinski_harabaz_score找到的最佳参数与silhouette_score找到的不一定相等"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "遇到一个严重问题，上面计算评估参数的结果，每次算出来都不一样，请老师在我作业上实验后给出原因\n",
    "请老师告知作业结果是否正确，如不正确，问题出在哪里，谢谢"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
